#include "FrameRenderFeature.h"
#include <SERender/Renderer/Renderer.h>
#include <SERender/Descriptors/FrameDescriptor.h>

namespace SEngine
{

    void FrameRenderFeature::BeginFrame()
    {
        auto frameDescriptor = m_renderer.AnyDescriptor::GetDescriptor<FrameDescriptor>();
        if (!frameDescriptor) {
            return;
        }
        m_renderer.GetDrive()->Viewport(frameDescriptor->get().x, frameDescriptor->get().y, frameDescriptor->get().w, frameDescriptor->get().h);
        m_renderer.GetDrive()->ClearColor(
            frameDescriptor->get().camera.GetClearColor().x,
            frameDescriptor->get().camera.GetClearColor().y,
            frameDescriptor->get().camera.GetClearColor().z,
            frameDescriptor->get().camera.GetClearColor().w
        );
        m_renderer.GetDrive()->Clear(frameDescriptor->get().camera.GetClearBuffer());
    }
    
} // namespace SEngine
